package com.hgy.crowd.api;

import com.hgy.crowd.util.ResultEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.concurrent.TimeUnit;

/**
 * @Author He
 * @Date 2020/6/30 16:47
 */
@FeignClient("hgy-crowd-redis")
public interface RedisRemoteService {
    /**
     * 设置String结构的数据，无生命周期
     * @param key
     * @param value
     * @return
     */
    @RequestMapping("/set/key/value/remote")
    ResultEntity<String> setStringKeyAndValueRemote(@RequestParam("key") String key,
                                                    @RequestParam("value") String value);

    /**
     * 设置具有生命周期的String数据
     * @param key
     * @param value
     * @param time
     * @param timeUnit
     * @return
     */
    @RequestMapping("/set/key/value/timeout/remote")
    ResultEntity<String> setStringKeyAndValueWithTimeoutRemote(@RequestParam("key")String key,
                                                               @RequestParam("value")String value,
                                                               @RequestParam("time")Long time,
                                                               @RequestParam("timeUnit") TimeUnit timeUnit);
    /**
     * 通过String的key值获取value
     * @param key
     * @return
     */
    @RequestMapping("/get/string/value/by/key")
    ResultEntity<String> getStringValueByKeyRemote(@RequestParam("key") String key);

    /**
     * 删除String数据值
     * @param key
     * @return
     */
    @RequestMapping("/remove/string/key")
    ResultEntity<String> removeRedisKeyRemote(@RequestParam("key") String key);
}
